home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / GNU_C++ / LIB / MTLB49CF.LZH / include / time.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-29  |  3.2 KB  |  132 lines

  1. /*
  2.  *    TIME.H        Date/Time related definitions
  3.  *     ansi draft sec  4.12
  4.  *
  5.  * changes by `-jerry' for POSIX(BSD) time-zone and tz-name
  6.  */
  7.  
  8. #ifndef    _TIME_H
  9. #define    _TIME_H
  10.  
  11. #ifndef _COMPILER_H
  12. #include <compiler.h>
  13. #endif
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. #define CLOCKS_PER_SEC    (200UL)              /* clock ticks per second */
  20. #define CLK_TCK         CLOCKS_PER_SEC            /* old name for this */
  21.  
  22. #ifndef NULL
  23. #define NULL __NULL
  24. #endif
  25.  
  26. #ifndef _TIME_T
  27. #define _TIME_T long
  28. typedef _TIME_T        time_t;
  29. #endif
  30.  
  31. #ifndef _SIZE_T
  32. #define _SIZE_T __SIZE_TYPEDEF__
  33. typedef _SIZE_T        size_t;
  34. #endif
  35.  
  36. typedef unsigned long    clock_t;
  37.  
  38. struct tm
  39. {
  40.     int    tm_sec;        /* seconds (0..59) */
  41.     int    tm_min;        /* minutes (0..59) */
  42.     int    tm_hour;    /* hours (0..23) */
  43.     int    tm_mday;    /* day of month (1..31) */
  44.     int    tm_mon;        /* month (0..11) */
  45.     int    tm_year;    /* year - 1900 */
  46.     int    tm_wday;    /* day of week (0=Sun..6=Sat) */
  47.     int    tm_yday;    /* day of year (0..365) */
  48.     int    tm_isdst;    /* daylight saving?  */
  49. #ifndef __STRICT_ANSI__
  50. /* -jerry */
  51. #define HAS_BSD_TIME 1
  52.     char *tm_zone;   /* abbreviation of timezone name */
  53.     long tm_gmtoff;  /* offset from UTC in seconds */
  54. #endif
  55. };
  56.  
  57. #ifndef __STRICT_ANSI__
  58. /* -jerry */
  59. #define HAS_TZNAME 1
  60. extern char *tzname[2];
  61. #endif
  62.  
  63.  
  64.  
  65. #ifndef __STRICT_ANSI__
  66. struct timeval {
  67.     long    tv_sec;        /* seconds */
  68.     long    tv_usec;    /* microseconds */
  69. };
  70.  
  71. struct timezone {
  72.     int    tz_minuteswest;    /* minues west of GMT */
  73.     int    tz_dsttime;    /* daylight savings time correction */
  74. };
  75.  
  76. #define    ITIMER_REAL    0
  77. #define    ITIMER_VIRTUAL    1
  78. #define    ITIMER_PROF    2
  79.  
  80. struct    itimerval {
  81.     struct    timeval it_interval;    /* timer interval */
  82.     struct    timeval it_value;    /* current value */
  83. };
  84. #endif
  85.  
  86. __EXTERN clock_t    clock     __PROTO((void));
  87. __EXTERN double        difftime __PROTO((time_t, time_t));
  88. #ifdef HAS_BSD_TIME
  89. __EXTERN time_t        mktime     __PROTO((struct tm * const ));
  90. __EXTERN time_t        time2posix __PROTO((time_t));
  91. __EXTERN time_t        posix2time __PROTO((time_t));
  92. #else
  93. __EXTERN time_t        mktime     __PROTO((struct tm * const ));
  94. #endif
  95. __EXTERN time_t        time     __PROTO((time_t *));
  96. __EXTERN char *     asctime     __PROTO((const struct tm *const));
  97. __EXTERN char *        ctime     __PROTO((const time_t * const));
  98. __EXTERN struct tm *    gmtime   __PROTO((const time_t * const));
  99. __EXTERN struct tm *    localtime __PROTO((const time_t * const));
  100. __EXTERN __SIZE_TYPEDEF__ strftime __PROTO((
  101.     char *s, size_t maxsize, const char *format, const struct tm *timeptr));
  102.  
  103. /* violation of ANSI standard, but POSIX wants it... sigh */
  104. __EXTERN void        tzset    __PROTO((void));
  105.  
  106. #if !defined(__STRICT_ANSI__) && !defined(_POSIX_SOURCE)
  107. __EXTERN clock_t    _clock     __PROTO((void));
  108. __EXTERN int    gettimeofday __PROTO((struct timeval *, struct timezone *));
  109. __EXTERN int    settimeofday __PROTO((struct timeval *, struct timezone *));
  110. __EXTERN int    getitimer __PROTO ((int, struct itimerval *));
  111. __EXTERN int    setitimer __PROTO ((int, const struct itimerval *,
  112.                     struct itimerval *));
  113.  
  114. #ifndef _FD_SET_T
  115. #define _FD_SET_T unsigned long
  116. typedef _FD_SET_T fd_set;
  117. #endif
  118.  
  119. __EXTERN int    select    __PROTO((int, fd_set *, fd_set *, fd_set *,
  120.                     struct timeval *));
  121.  
  122. #define timercmp(tva, tvb, op) \
  123.     ((tva)->tv_sec op (tvb)->tv_sec || \
  124.      ((tva)->tv_sec == (tvb)->tv_sec && (tva)->tv_usec op (tvb)->tv_usec))
  125. #endif
  126.  
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130.  
  131. #endif /* _TIME_H */
  132.